#include "stdafx.h"
#include "TemplateWindow.h"

#include <metaioSDK/IMetaioSDK.h>
#include <QtWidgets/QApplication>
#include "AppConfig.h"

#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")

int main(int argc, char *argv[])
{
	/*HWND hConsole = GetConsoleWindow();
	if (hConsole)
		ShowWindow(hConsole, SW_HIDE);*/

	bool isNoWindow = false;
	if (AppConfig::instance()->cmdline.find("-nw") != std::string::npos)
		isNoWindow = true;
	
	if (!isNoWindow) {
		AllocConsole();
		freopen("CON", "w", stdout);
	}

	QApplication a(argc, argv);
	UEditorMsgEater msgEater(&a);
	a.installNativeEventFilter(&msgEater);

	TemplateWindow w;
	if (!isNoWindow)
		w.show();
	else
		w.forceRecognize();

	int res = a.exec();

	metaio::IMetaioSDK::shutdownLibrary();

	return res;
}
